package com.caigou.controller;

import com.caigou.component.ueditor.ActionEnter;
import io.swagger.annotations.Api;
import org.json.JSONException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;

@Api(value = "富文本编辑器配置类")
@RestController
@RequestMapping("/ueditor")
public class UEditorController {

    @RequestMapping("/exec")
    @ResponseBody
    public String exec(HttpServletRequest request) throws UnsupportedEncodingException, JSONException {
        request.setCharacterEncoding("utf-8");
        String rootPath = request.getRealPath("/");
        String actionEnter = new ActionEnter( request, rootPath ).exec();
        return actionEnter;
    }
}
